

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/sys/layuiadmin/layui/css/layui.css" media="all">
</head>
<body>

<div class="layui-form" lay-filter="formTest" id="formTest" style="padding: 20px 30px 0 0;">
    <div class="layui-form-item">
        <label class="layui-form-label">商品名</label>
        <div class="layui-input-inline">
            <input type="text" name="name" id="name" lay-verify="required" placeholder="请输入商品名" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">商品编号</label>
        <div class="layui-input-inline">
            <input type="text" name="code" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">类型</label>
        <div class="layui-input-inline">
            <select name="type" id="lx_comm_type" lay-verify="required" lay-search></select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-inline">
            <input type="checkbox" lay-verify="required" lay-filter="status" id="status" name="status" lay-skin="switch" lay-text="有效|无效" checked>
        </div>
    </div>
    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="layuiadmin-app-form-submit" id="layuiadmin-app-form-submit" value="确认添加">
        <input type="button" lay-submit lay-filter="layuiadmin-app-form-edit" id="layuiadmin-app-form-edit" value="确认编辑">
    </div>
</div>
<script src="/sys/layuiadmin/js/jquery.min.js"></script>
<script src="/sys/layuiadmin/layui/layui.all.js"></script>
<script src="/sys/layuiadmin/js/lx.js"></script>
<script src="../jea.js"></script>
<script>
    var id = lx.request("id");
    layui.config({
        base: '/sys/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form'], function(){
        var $ = layui.$
                ,form = layui.form;
        //监听提交
        form.on('submit(layuiadmin-app-form-submit)', function(data){
            var field = data.field; //获取提交的字段
            field.status = field.status == 'on'?'1':'0';
            if(id){
                field.id = id;
                field.lx_id = id;
            }else{
                field.id = '1';
                field.addTime= '1';
            }

            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            lx.ajax("app/edit/comm",function () {
                parent.layui.table.reload('table_temp_id'); //重载表格
                parent.layer.close(index); //再执行关闭
            },field);
        });
    })
    if(id){
        lx.ajax("app/obj/comm",function (data) {
            var v = data.entity;
            v.status = v.status=='1'?true:false;
            layui.form.val("formTest",v);
        },{lx_id:id});
    }
</script>
</body>
</html>